<html class="hb-loaded">
 <head> 
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> 
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> 
  <meta content="yes" name="apple-mobile-web-app-capable" /> 
  <meta content="black" name="apple-mobile-web-app-status-bar-style" /> 
  <meta content="telephone=no" name="format-detection" /> 
  <meta content="email=no" name="format-detection" /> 
  <title>购物车 - 空</title> 
 
  <script src="js/jquery.min.js"></script> 
  <script src="js/bootstrap.min.js"></script> 
  <link rel="stylesheet" href="css/bootstrap.min.css" /> 
  <link rel="stylesheet" href="css/public.v20150930.css" /> 
  <script src="js/ygop.ajax.client.js"></script> 
  <script src="js/Common.v150812.js"></script> 
  <script src="js/layer.m.js"></script> 
  <link rel="stylesheet" href="css/layer.css" /> 
  <script src="js/jweixin-1.0.0.js" type="text/javascript"></script> 
  <link rel="stylesheet" href="css/gps.css" /> 




 </head> 
 <body> 
  <link rel="stylesheet" href="css/cart.css" /> 
  <script type="text/javascript" src="js/jquery.lazyload.min.js"></script> 
  <div style="display:none" id="divCart" class="wrap pt120"> 
   <div id="divCartProductList" class="cart_list"> 
   </div> 
   <div class="discount"> 
    <div style="display:none" class="discount-title" id="discount-title">
     <span></span>优惠商品
    </div> 
    <ul id="ulCartGiftList"></ul> 
   </div> 
   <div class="clear_cart">
    <a id="btnClearCart">清空购物车</a>
   </div> 
   <div class="payment_total"> 
    <div class="shp_cart_info"> 
     <span class="sale_off">优惠:<strong id="discountAmount">￥0.00</strong></span> 
     <span class="shp_cart_total">总计:<strong id="totalPrice">￥0.00</strong></span> 
    </div> 
    <a id="btnGoPay" class="btn_right">去结算(<span id="giftTotalCount">0</span>)</a> 
   </div> 
  </div> 
  <div style="" id="divEmptyCart" class="wrap cartnonewrap"> 
   <div class="cart-none"> 
    <div class="cart-bg"> 
     <span>购物车是空的</span> 
    </div> 
    <div>
     <a href="index.html">去逛逛</a>
    </div> 
   </div> 
  </div> 
  <script>
    //默认占位符图片
    var placeholderImg = "http://img02.yiguo.com/e/web/150930/00982/163525/placeholder_140x140.png";

    $(function () {
        $(".footer a").removeClass();
        $(".footer #cart").addClass("current");
        clearCookieCartOperate();
        getCartProductList();
    })
    //去结算操作
    function gotToPayOperate() {
        $("#btnGoPay").click(function () {
            window.location.href = "/settle";
        })
    }

    //清空购物车
    function clearCookieCartOperate() {
        $("#btnClearCart").click(function () {
            YgmJsCommon.popups.confirm("您确定要清空购物车的商品吗？", function () {
                YgmJsCommon.clearCartProducts();
                $("#divCart").css("display", "none");
                $("#divEmptyCart").css("display", "");
                //返回商品数量显示在footer上
                // var count = YgmJsCommon.getCartProductsTotalCount();
                // $("#fCartProductTotalCount").html(count);
                getCartCount();
            })
        })
    }

    //修改输入商品操作
    function updateOperate() {
        $("#divCartProductList").find(".itxt").each(function (i, n) {
            $(this).click(function (event) {
                event.stopPropagation();
            });

            $(this).change(function (event) {
                event.stopPropagation();
                if (!$.isNumeric($(this).val())) {
                    YgmJsCommon.popups.alert("商品数量格式不正确");
                    return;
                }

                var cid = $(this).attr("cid");
                var ccode = $(this).attr("ccode");
                var amount = parseInt($(this).val());
                var maxLimitCount = parseInt($(this).attr("maxLimitCount"));
                if (amount < 1) {
                    $(this).val($(this).attr("amount"));
                    return;
                }
                if (amount > maxLimitCount) {
                    $(this).val($(this).attr("amount"));
                    YgmJsCommon.popups.alert("最大购买数量不能超过" + maxLimitCount);
                    return;
                }
                if (amount > 99) {
                    $(this).val($(this).attr("amount"));
                    return;
                }
                var commodity = {};
                commodity.Id = cid;
                commodity.Code = ccode;
                commodity.Amount = amount;
                commodity.GId = "";
                var bl = YgmJsCommon.updateCartProcuct(commodity);
                if (bl) {
                    getCartProductList();
                }
            })
        })
    }

    //+商品操作
    function incrementOperate() {
        $("#divCartProductList").find(".increment").each(function (i, n) {
            $(this).click(function (event) {
                event.stopPropagation();
                var cid = $(this).attr("cid");
                var ccode = $(this).attr("ccode");
                var amount = parseInt($(this).attr("amount"));
                var maxLimitCount = parseInt($(this).attr("maxLimitCount"));

                if (amount + 1 > maxLimitCount) {
                    YgmJsCommon.popups.alert("最大购买数量不能超过" + maxLimitCount);
                    return;
                }

                if (amount > 98) {
                    return;
                }

                var commodity = {};
                commodity.Id = cid;
                commodity.Code = ccode;
                commodity.Amount = amount;
                commodity.GId = "";
                var bl = YgmJsCommon.updateCartProcuct(commodity, 1);
                if (bl) {
                    getCartProductList();
                }
            })
        })
    }

    //-商品操作
    function decrementOperate() {
        $("#divCartProductList").find(".decrement").each(function (i, n) {
            $(this).click(function (event) {
                event.stopPropagation();
                var cid = $(this).attr("cid");
                var ccode = $(this).attr("ccode");
                var amount = parseInt($(this).attr("amount"));

                if (amount - 1 <= 0) {
                    return;
                }
                var commodity = {};
                commodity.Id = cid;
                commodity.Code = ccode;
                commodity.Amount = amount;
                commodity.GId = "";
                var bl = YgmJsCommon.updateCartProcuct(commodity, 2);
                if (bl) {
                    getCartProductList();
                }
            })
        })
    }

    //删除商品操作
    function delOperate() {
        $("#divCartProductList").find(".del-btn").each(function (i, n) {
            $(this).click(function (event) {
                event.stopPropagation();
                var cid = $(this).attr("cid");
                YgmJsCommon.popups.confirm("您确定要删除该商品", function () {
                    YgmJsCommon.delCartProcuct(cid);
                    getCartProductList();
                })
            })
        })
    }

    //转到商品详情操作
    function goToProductOperate() {
        $("#divCartProductList").find("li").each(function (i, n) {
            $(this).click(function () {
                var ccode = $(this).attr("ccode");
                window.location.href = "/product/" + ccode + ".html";
            })

        });

        $("#ulCartGiftList").find("li").each(function (i, n) {
            $(this).click(function () {
                var ccode = $(this).attr("ccode");
                window.location.href = "/product/" + ccode + ".html";
            })
        });
    }

    //获取购物车商品列表
    function getCartProductList() {
//        YgmJsCommon.popups.loading();
    }

    //获取商品规格
    function getProductSpec(spec) {
        var retSpec = "";
        if (spec != undefined && spec != "") {
            retSpec = '(' + spec + ')';
        }
        return retSpec;
    }

    //判断是否赠，惠，享，限，配Promotions
    function displayProductPromotions(promotions) {
        var html = "";
        if (promotions) {
            html += '<div class="promotion_tip"><ul>';
            for (var i = 0; i < promotions.length; i++) {
                var flag = promotions[i].SaleFlag;
                if (flag == 1) {
                    html += '<li><span class="tit tit4">买即赠</span><span>' + promotions[i].SaleText + '</span></li>';
                }
                else if (flag == 2) {
                    html += '<li><span class="tit tit3">优惠券</span><span>' + promotions[i].SaleText + '</span></li>';
                }
                if (flag == 3) {
                    html += '<li><span class="tit tit1">超值限购</span><span>' + promotions[i].SaleText + '</span></li>';
                }
                else if (flag == 4) {
                    html += '<li><span class="tit tit2">手机专享</span><span>' + promotions[i].SaleText + '</span></li>';
                }
                else if (flag == 5) {
                    html += '<li><span class="tit tit5">限时配送</span><span>' + promotions[i].SaleText + '</span></li>';
                }
                else if (flag == 6) {
                    html += '<li><span class="tit tit6">闪电购</span>' + promotions[i].SaleText + '</span></li>';
                }
            }
            html += '</ul></div>';
        }
        return html;
    }
</script> 
  <footer class="footer"> 
   <a class="" href="index.html" id="index"><span class="home">首页</span>首页</a> 
   <a href="cat.html" id="category"><span class="catalog">分类</span>分类</a> 
   <a href="cart.html" id="cart" class="current"> <span class="shopping">购物车<font id="fCartProductTotalCount" class="badge" style="display: none;"></font></span>购物车 </a> 
   <a href="member_index.html" id="my"><span class="my">我的易果</span>我的易果</a> 
  </footer> 
  <div data-backdrop="static" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="divMyCity" class="modal" style="display: none;"> 
   <div role="document" class="modal-dialog"> 
    <div id="divCityContent" class="modal-content"> 
     <div style=" display:block;" class="gpstips"> 
      <a> <em class=" icon icon_gps"> </em> 亲，请先选择您的收货城市 <em class=" icon icon_arrowright"> </em> </a> 
     </div> 
    </div> 
   </div> 
  </div> 
  <script type="text/javascript">
        var _wx_JsConfig = {};
        _wx_JsConfig.appid = "wx0d4f4f0e0bada80e";
        _wx_JsConfig.imgUrl = "http://img02.yiguo.com/e/web/150930/00783/155744/wxlogo.jpg";
        _wx_JsConfig.title = "易果生鲜触屏版";
        _wx_JsConfig.content = "全国首家生鲜专业电商，全球优质生鲜产地直供，全年无休生鲜冷链配送";
        _wx_JsConfig.timeLineLink = "http://weixin.m.yiguo.com";

        _wx_JsConfig.timestamp = "";
        _wx_JsConfig.nonceStr = "";
        _wx_JsConfig.signature = "";

        $(function () {
            YgmJsCommon.domain = "yiguo.com";
            var jsonWxCfg = decodeURIComponent("%7b%22appId%22%3anull%2c%22timestamp%22%3a%221445765261%22%2c%22nonceStr%22%3a%221309023886%22%2c%22signature%22%3a%22f1466e76e657e78be76bcd4c208e7d3ce31b8ca1%22%2c%22url%22%3a%22http%3a%2f%2fweixin.m.yiguo.com%2fmycart%22%2c%22jsapi_ticket%22%3a%22bxLdikRXVbTPdHSM05e5u_n3yqdZ_9Pt0dvnbtzvrXZ2Bps91PjRajJdScVYkXWafhoi6zfSwxWok0rXn11cmQ%22%7d");
            var wxJsCfg = JSON.parse(jsonWxCfg);
            _wx_JsConfig.timestamp = wxJsCfg.timestamp;
            _wx_JsConfig.nonceStr = wxJsCfg.nonceStr;
            _wx_JsConfig.signature = wxJsCfg.signature;

            wx.config({
                //debug: true,
                appId: _wx_JsConfig.appid,
                timestamp: _wx_JsConfig.timestamp,
                nonceStr: _wx_JsConfig.nonceStr,
                signature: _wx_JsConfig.signature,
                jsApiList: [
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage'
                ]
            });

            myShare();

            getCartCount();

            showSelectedCityDialog();
        })

        function myShare() {
            wx.ready(function () {
                //分享朋友圈
                wx.onMenuShareTimeline({
                    title: _wx_JsConfig.title,
                    desc: _wx_JsConfig.content, // 分享描述
                    link: _wx_JsConfig.timeLineLink,
                    imgUrl: _wx_JsConfig.imgUrl,
                    trigger: function (res) {
                    },
                    success: function (res) {
                        dplus.track("分享到朋友圈");
                    },
                    cancel: function (res) {
                    },
                    fail: function (res) {
                    }
                });
                //分享朋友
                wx.onMenuShareAppMessage({
                    title: _wx_JsConfig.title,
                    desc: _wx_JsConfig.content,
                    link: _wx_JsConfig.timeLineLink,
                    imgUrl: _wx_JsConfig.imgUrl,
                    trigger: function (res) {
                    },
                    success: function (res) {
                        dplus.track("分享给朋友");
                    },
                    cancel: function (res) {
                    },
                    fail: function (res) {
                    }
                });
            });

        }

        //如果查询到CityCookie default=1，表示用户没有选择过城市，则需要弹出选择城市
        function showSelectedCityDialog() {
            var objCity = YgmJsCommon.getCityCookie();
            if (objCity != null && objCity.Default == 1) {
                $("#divMyCity").css('display', "");
                $("#divMyCity").modal('show');
                $("#divMyCity").click(function () {
                    window.location.href = "/Home/SelectCity";
                })
            }
            else {
                $("#divMyCity").css('display', "none");
            }
        }

        //返回商品数量显示在footer上
        function getCartCount() {
            var count = YgmJsCommon.getCartProductsTotalCount();
            if (count > 0) {
                $("#fCartProductTotalCount").css("display", "");
                $("#fCartProductTotalCount").html(count);
            }
            else {
                $("#fCartProductTotalCount").css("display", "none");
            }
            return count;
        }

        //设置云朵的位置
        $('#divMyCity').on('shown.bs.modal', function () {
            var win_width = $(this).find(".modal-dialog").width();
            var win_height = $(this).find(".modal-dialog").height();
            $(this).find(".modal-dialog").css({ "marginTop": String(-1 * win_height / 2) + "px", "marginLeft": String(-1 * win_width / 2) + "px" });

        });

        window.onload = function () {
            
        };
    </script> 
 </body>
</html>